As described in Sharing, Trilium can act as a public server in which the shared notes are displayed in read-only mode. While this can work in most cases, it's generally not meant for high-traffic websites and since it's running on a Node.js server it can be potentially exploited.
Another alternative is to generate static HTML files (just like other static site generators such as MkDocs). Since the normal HTML ZIP export does not contain any styling or additional functionality, Trilium provides a way to export the same layout and style as the Sharing function into static HTML files.
Apart from the enhanced security, these HTML files are also easy to deploy on “serverless” deployments such as GitHub Pages or CloudFlare Pages and cache very easily.
Apart from normal Sharing, exporting to static HTML files comes with a few subtle differences:
example.com/share/noteid,
the notes follow an hierarchical structure, such as docs.triliumnotes.org/user-guide/concepts/navigation/tree-concepts.favicon.ico is not handled automatically,
it needs to be manually added on the server after the export is generated.shareAlias to
allow for clean URLs.As mentioned previously, the exported static pages require a website to function. In order to test locally, a web server needs to be used.
One example is to use the Node.js-based http-server which
can be installed via:
npm i -g http-server
Once installed simply:
http-server.ETAPI (REST API) could potentially be used to automate an export on a scheduled task.